package com.eco.fanliapp.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.eco.fanliapp.service.*;
import com.eco.fanliapp.utils.ComputeUtil;
import com.eco.fanliapp.utils.DateFormatUtils;
import com.eco.fanliapp.utils.DateUtils;
import com.eco.fanliapp.utils.OpenApiUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;

/**
 * 后台管理统计
 */
@Service
public class StatisticsServiceImpl implements IStatisticsService {

    @Autowired
    private IAppUserService iAppUserService;

    @Autowired
    private IAppOrderDetailService iAppOrderDetailService;

    @Autowired
    private IAppUserOrderService iAppUserOrderService;

    @Autowired
    private IAppWithdrawalService iAppWithdrawalService;

    @Autowired
    private IAppUserSearchHistoryService iAppUserSearchHistoryService;

    @Autowired
    private IAppUserRedRewardService iAppUserRedRewardService;

    @Autowired
    private ISyUserMoneyService syUserMoneyService;

    @Autowired
    private IAppUserOrderService appUserOrderService;

    @Autowired
    private RedisTemplateService redisTemplateService;

    @Autowired
    private IMtOrderDetailService promoteVerifyItemDataService;

    /**
     * 统计接口汇总
     * @return
     */
    @Override
    public JSONObject staticList() {
        //缓存更新时间
        String redisKey = "staticList_" + DateFormatUtils.getNowDateDay(new Date()) + "_MM";
        if(redisTemplateService.hasKey(redisKey)){
            Object jsonObject = redisTemplateService.getObj(redisKey);
            return (JSONObject) jsonObject;
        }else{
            return null;
        }
//        JSONObject jsonObject = new JSONObject(true);
//        //昨日美团佣金及订单数
//        Map<String,Object> mtMap = promoteVerifyItemDataService.mtBalanceAmount();
//        jsonObject.put("mt_balance_amount",mtMap.get("balanceAmount"));
//        jsonObject.put("mt_order_num",mtMap.get("orderNum"));
//        return jsonObject;

    }




    @Override
	@Async
    public void otherList() {
        //缓存更新时间
        String redisKey = "staticList_" + DateFormatUtils.getNowDateDay(new Date()) + "_MM";

        JSONObject jsonObject = new JSONObject(true);
        //===========莫莫=======
        //昨天省钱间谍的注册用户 5
        Integer sqjd_num = iAppUserService.sqjdRegistNum();
        jsonObject.put("sqjd_num",sqjd_num);
        //昨天省钱间谍的首单用户（免单不算）  7
        Integer sqjd_order = appUserOrderService.sqjdOrderNum();
        jsonObject.put("sqjd_order",sqjd_order);
        //昨天省钱间谍佣金  佣金  1265.69  联盟：2137.46
        Map<String,Double> map = appUserOrderService.sqjdCommision();
        jsonObject.put("sqjd_commisssion",map.get("commission"));
        jsonObject.put("sqjd_pubSharePreFee",map.get("pubSharePreFee"));
        //昨天省钱间谍的提现金额（转账成功的） 1917.78
        Double sqjd_withdrawal = iAppWithdrawalService.sqjdWithdrawal();
        jsonObject.put("sqjd_withdrawal",sqjd_withdrawal);
        //昨日所有支付宝提现：
        Double zfb_money = iAppWithdrawalService.withdrawalAllMoney(1);
        jsonObject.put("zfb_money",zfb_money);
        //所有微信提现：
        Double wx_money = iAppWithdrawalService.withdrawalAllMoney(2);
        jsonObject.put("wx_money",wx_money);
        //昨日美团佣金及订单数
        Map<String,Object> mtMap = promoteVerifyItemDataService.mtBalanceAmount();
        jsonObject.put("mt_balance_amount",mtMap.get("balanceAmount"));
        jsonObject.put("mt_order_num",mtMap.get("orderNum"));

        //《社群部》：
        //返佣(不包括后返)：2249.7 联盟佣金(不包括后返)：4137.41
        Map<String,Double> map21 = appUserOrderService.sqjdTypeCommision(42,0,0);
        jsonObject.put("sqb_bbkhf_commisssion",map21.get("commission"));
        jsonObject.put("sqb_bbkhf_pubSharePreFee",map21.get("pubSharePreFee"));
        //后返返佣：294.3 后返联盟佣金：239.24
        Map<String,Double> map22 = appUserOrderService.sqjdTypeCommision(42,1,0);
        jsonObject.put("sqb_hf_commisssion",map22.get("commission"));
        jsonObject.put("sqb_hf_pubSharePreFee",map22.get("pubSharePreFee"));
        //新人免单返佣：18.6 新人免单联盟佣金：15.49
        Map<String,Double> map23 = appUserOrderService.sqjdTypeCommision(42,null,1);
        jsonObject.put("sqb_xrmd_commisssion",map23.get("commission"));
        jsonObject.put("sqb_xrmd_pubSharePreFee",map23.get("pubSharePreFee"));

        //《总公司》：
        //返佣(不包括后返)：30166.42 联盟佣金(不包括后返)：59870.21
        Map<String,Double> map31 = appUserOrderService.sqjdTypeCommision(1,0,0);
        jsonObject.put("zgs_bbkhf_commisssion",map31.get("commission"));
        jsonObject.put("zgs_bbkhf_pubSharePreFee",map31.get("pubSharePreFee"));
        //后返返佣：198.3 后返联盟佣金：165.34
        Map<String,Double> map32 = appUserOrderService.sqjdTypeCommision(1,1,0);
        jsonObject.put("zgs_hf_commisssion",map32.get("commission"));
        jsonObject.put("zgs_hf_pubSharePreFee",map32.get("pubSharePreFee"));
        //新人免单返佣：294.8 新人免单联盟佣金：209.28
        Map<String,Double> map33 = appUserOrderService.sqjdTypeCommision(1,null,1);
        jsonObject.put("zgs_xrmd_commisssion",map33.get("commission"));
        jsonObject.put("zgs_xrmd_pubSharePreFee",map33.get("pubSharePreFee"));

        //《总佣金（所有用户）》：
        //返佣(不包括后返)：32430.24 联盟佣金(不包括后返)：64028.38
        Map<String,Double> map41 = appUserOrderService.sqjdTypeCommision(null,0,0);
        jsonObject.put("syyh_bbkhf_commisssion",map41.get("commission"));
        jsonObject.put("syyh_bbkhf_pubSharePreFee",map41.get("pubSharePreFee"));
        //后返返佣：494.5 后返联盟佣金：406.1
        Map<String,Double> map42 = appUserOrderService.sqjdTypeCommision(null,1,0);
        jsonObject.put("syyh_hf_commisssion",map42.get("commission"));
        jsonObject.put("syyh_hf_pubSharePreFee",map42.get("pubSharePreFee"));
        //返佣(包括后返)：32924.74 联盟佣金(包括后返)：64434.48
        Map<String,Double> map43 = appUserOrderService.sqjdTypeCommision(null,null,0);
        jsonObject.put("syyh_commisssion",map43.get("commission"));
        jsonObject.put("syyh_pubSharePreFee",map43.get("pubSharePreFee"));
        //新人免单返佣：349.7 新人免单联盟佣金：251.52
        Map<String,Double> map44 = appUserOrderService.sqjdTypeCommision(null,null,1);
        jsonObject.put("syyh_xrmd_commisssion",map44.get("commission"));
        jsonObject.put("syyh_xrmd_pubSharePreFee",map44.get("pubSharePreFee"));

        //==============胡梦云=========
        //《省钱间谍》
        Map<String,Object> map4 = iAppWithdrawalService.withdrawalCommision(1);
        jsonObject.put("zrsqjd_money",map4.get("amount"));
        jsonObject.put("zrsqjd_nums",map4.get("nums"));
        //《省鸭》
        Map<String,Object> map5 = iAppWithdrawalService.withdrawalCommision(2);
        jsonObject.put("zrsy_money",map5.get("amount"));
        jsonObject.put("zrsy_nums",map5.get("nums"));

        //==============邰有鑫============
        //昨天省钱间谍的注册用户 3
        jsonObject.put("zrsqjd_num",sqjd_num);
        //昨天省钱间谍的首单用户（免单不算）10
        jsonObject.put("zrsqjd_order",sqjd_order);
        //昨天省钱间谍佣金  佣金  1238.87  联盟：2096.08
        jsonObject.put("zrsqjd_commisssion",map.get("commission"));
        jsonObject.put("zrsqjd_pubSharePreFee",map.get("pubSharePreFee"));
        //昨天省钱间谍的提现金额（转账成功的） 1859.55
        Double sqjd_all_money = iAppWithdrawalService.sqjdWithdrawalCommision();
        jsonObject.put("sqjd_all_money",sqjd_all_money);
        //省钱间谍所有注册用户：2361
        Integer sqjd_all_nums = iAppUserService.sqjdAllRegistNum();
        jsonObject.put("sqjd_all_nums",sqjd_all_nums);
        //省钱间谍所有下单用户：1974
        Integer sqjd_all_order = appUserOrderService.sqjdAllOrderNum();
        jsonObject.put("sqjd_all_order",sqjd_all_order);
        //Integer type = 1;//公司类型
        //Integer flag = 1;//提现类型
        //《2020-02-21总公司省所有的提现记录》
        //支付宝：钱：8549.46    人：567
        Map<String,Object> map6 = iAppWithdrawalService.withdrawalResultCommision(2,1);
        jsonObject.put("zgs_zfb_money",map6.get("amount"));
        jsonObject.put("zgs_zfb_nums",map6.get("nums"));
        //微  信：钱：372.00     人：157
        Map<String,Object> map7 = iAppWithdrawalService.withdrawalResultCommision(2,2);
        jsonObject.put("zgs_wx_money",map7.get("amount"));
        jsonObject.put("zgs_wx_nums",map7.get("nums"));
        //《2020-02-21省钱间谍的提现记录》
        //支付宝：钱：1842.55     人：47
        Map<String,Object> map8 = iAppWithdrawalService.withdrawalResultCommision(1,1);
        jsonObject.put("sqjd_zfb_money",map8.get("amount"));
        jsonObject.put("sqjd_zfb_nums",map8.get("nums"));
        //微  信：钱：17.00  		人：5
        Map<String,Object> map9 = iAppWithdrawalService.withdrawalResultCommision(1,2);
        jsonObject.put("sqjd_wx_money",map9.get("amount"));
        jsonObject.put("sqjd_wx_nums",map9.get("nums"));

        Map<String,Object> map10 =appUserOrderService.freeCommssion();
        //总公司昨日免单联盟佣金: 213.91
        jsonObject.put("zgs_free_pubSharePreFree",map10.get("pubSharePreFree"));
        //总公司昨日免单补贴金额：263.60
        jsonObject.put("zgs_free_commission",map10.get("commission"));
        //昨日免单单数：44
        jsonObject.put("zgs_free_orders",map10.get("orders"));
        //总公司昨日免单单笔成本(补贴金额 - 联盟金额）/ 订单数)：1.13
        jsonObject.put("zgs_free_percent",map10.get("percent"));
        //总公司昨日注册量：294
        Integer zgs_regist = iAppUserService.zgsAllRegistNum(1);
        jsonObject.put("zgs_regist",zgs_regist);
        //总公司累计注册用户：103945
        Integer zgs_all_regist = iAppUserService.zgsAllRegistNum(2);
        jsonObject.put("zgs_all_regist",zgs_all_regist);
        //新增下单用户（新A）：247
        Integer add_order_num = iAppUserService.addPayOrder(1);
        jsonObject.put("add_order_num",add_order_num);
        //累积下单用户(累计总A产出)：52714
        Integer add_all_order_num = iAppUserService.addPayOrder(2);
        jsonObject.put("add_all_order_num",add_all_order_num);
        //总公司昨日联盟佣金：26880.18
        Double zgs_all_commission = appUserOrderService.zgsAllCommission();
        jsonObject.put("zgs_all_commission",zgs_all_commission);
        //1.总公司里面中间页3
        Map<String,Object> map11 = appUserOrderService.selectChannelNums(3);
        jsonObject.put("zjy_nums",map11.get("nums"));
        jsonObject.put("zjy_money",map11.get("money"));
        //2.主动私聊4
        Map<String,Object> map12 = appUserOrderService.selectChannelNums(4);
        jsonObject.put("zdsl_nums",map12.get("nums"));
        jsonObject.put("zdsl_money",map12.get("money"));
        //3.自动回复5
        Map<String,Object> map13 = appUserOrderService.selectChannelNums(5);
        jsonObject.put("zdhf_nums",map13.get("nums"));
        jsonObject.put("zdhf_money",map13.get("money"));

        //总公司省钱间谍2号提现人id
        List<String> list = iAppWithdrawalService.selectUserIdList();
        jsonObject.put("sqjd_userid",list);

        //添加缓存
        redisTemplateService.set(redisKey,jsonObject,3600*24);

    }



    /**
     *
     * @param day 1 昨天  默认 今天
     * @return
     */
    private static long beginDay(Integer day) {
        long current = System.currentTimeMillis();//当前时间毫秒数
        if (day == 1) {
             current = current - 24 * 3600 * 1000;    //昨天
        }
        return current / (1000 * 3600 * 24) * (1000 * 3600 * 24) - TimeZone.getDefault().getRawOffset();  //今天零点零分零秒的毫秒数
    }

    /**
     * @param day 1 昨天  默认 今天
     * @return
     */
    private static  long endDay(Integer day){
        return beginDay(day)+24*60*60*1000-1;  //今天23点59分59秒的毫秒数
    }

    private    long nearOneMonth(){
        Date date = DateFormatUtils.beforeDate(new Date(), 31);
        return date.getTime();
    }

    /**
     *  百分比转换
     * @param molecule  分子
     * @param denominator 分母
     * @return
     */
    private String toPercentage(int molecule,int denominator){
        if(denominator == 0){
            return "0";
        }
        NumberFormat numberFormat = NumberFormat.getInstance();
        numberFormat.setMaximumFractionDigits(2);
        String totalNoBuyProportion = numberFormat.format((float) molecule / (float) denominator * 100);
        return totalNoBuyProportion;
    }

    private double handleDoubleDiv(Double a,Integer b){
        if(a == null || b == null || b== 0){
            return 0D;
        }
        double va = a.doubleValue();
        double vb = b.doubleValue();
        //System.out.println(va);
        //System.out.println(vb);
       return ComputeUtil.div(va, vb, 2);
    }
    @Override
    public JSONObject jsonList(Integer companyId) {
        //缓存更新时间
        String redisKey = "jsonList_" + DateFormatUtils.getNowDateDay(new Date()) + "_" + companyId;
        if(redisTemplateService.hasKey(redisKey)){
            Object jsonObject = redisTemplateService.getObj(redisKey);
            return (JSONObject) jsonObject;
        }else{
            return null;
        }
//        //今日开始时间
//        long startTime = DateUtils.getTimesmorning().getTime();
//        //今日结束时间
//        long endTime = DateUtils.getTimesnight().getTime();
//        //昨日开始时间
//        long yestarStartTime = DateUtils.getYesterdaymorning().getTime();
//
//        JSONObject jsonObject = new JSONObject(true);
//        //1-1-1.总注册人数
//        int hytj_zzcrs = iAppUserService.totalNumberYesterday(companyId,0);
//        jsonObject.put("hytj_zzcrs",hytj_zzcrs);
//        //1-2-1.总下单用户
//        Integer hytj_zxdyh = appUserOrderService.totalOrderUserRegistration(companyId);
//        jsonObject.put("hytj_zxdyh",hytj_zxdyh);
//
//        //2-7-1.总单粉产出(总有效佣金/总注册量)
//        Double zyxyj = iAppUserOrderService.statisticsCommission(0, companyId,startTime, endTime);
//        jsonObject.put("zyxyj",zyxyj);
//        jsonObject.put("ddtj_zdfcc",handleDoubleDiv(zyxyj,hytj_zzcrs));
//        //2-7-3.昨日单粉产出(昨日有效佣金/昨日注册量)
//        Double zryxyj = iAppUserOrderService.statisticsCommission(2, companyId, startTime, endTime);
//        jsonObject.put("ddtj_zrdfcc",handleDoubleDiv(zryxyj,hytj_zzcrs));
//
//
//        //2-8-1.总A用户单产(总有效佣金/总新增下单用户)
//        jsonObject.put("ddtj_zayhdc",handleDoubleDiv(zyxyj,hytj_zxdyh));
//        //2-8-3.昨日A用户单产(昨日有效佣金/总新增下单用户）
//        jsonObject.put("ddtj_zrayhdc",handleDoubleDiv(zryxyj,hytj_zxdyh));
//
//        return  jsonObject;
    }

    @Override
    public JSONObject jsonTabList(Integer companyId,int type ) {
        String redisKey = "jsonTabList_" + type + "_" + DateFormatUtils.getNowDateDay(new Date()) + "_" + companyId;
        if(redisTemplateService.hasKey(redisKey)){
            Object jsonObject = redisTemplateService.getObj(redisKey);
            return (JSONObject) jsonObject;
        }else{
            return null;
        }

    }

    @Override
    @Async
    public void jsonListTask(Integer companyId) {
        //缓存更新时间
        String redisKey = "jsonList_" + DateFormatUtils.getNowDateDay(new Date()) + "_" + companyId;
        //统计维度标识（0：全部；1：今日；2：昨日）
        Integer flag = 0;
        //============《1.会员统计》==============
		//今日开始时间
		long startTime = DateUtils.getTimesmorning().getTime();
		//今日结束时间
		long endTime = DateUtils.getTimesnight().getTime();
		//昨日开始时间
		long yestarStartTime = DateUtils.getYesterdaymorning().getTime();

		JSONObject jsonObject = new JSONObject(true);
        //1-1-1.总注册人数
        int hytj_zzcrs = iAppUserService.totalNumberYesterday(companyId,flag);
        jsonObject.put("hytj_zzcrs",hytj_zzcrs);
        //1-1-2.今日注册数
        //int hytj_jrzcs = iAppUserService.totalNumberYesterday(companyId,1);
        jsonObject.put("hytj_jrzcs",0);
        //1-1-3.昨日注册数
        int hytj_zrzcs = iAppUserService.totalNumberYesterday(companyId,2);
        jsonObject.put("hytj_zrzcs",hytj_zrzcs);
        //1-2-1.总下单用户
        Integer hytj_zxdyh = appUserOrderService.totalOrderUserRegistration(companyId);
        jsonObject.put("hytj_zxdyh",hytj_zxdyh);
        //1-2-2.今日新增A人数（新增下单用户）
        //Integer hytj_jrxzars = iAppUserOrderService.yesterdayAddingUsers(companyId,1);
        jsonObject.put("hytj_jrxzars",0);
        //1-2-3.昨日新增A人数（新增下单用户）
        Integer hytj_zrxzars = iAppUserOrderService.yesterdayAddingUsers(companyId,2);
        jsonObject.put("hytj_zrxzars",hytj_zrxzars);
        //1-3-1.总查B用户（总查券未购买）
        int hytj_zcbyh = iAppUserSearchHistoryService.selectCountSearchCouponPeople(companyId);
        jsonObject.put("hytj_zcbyh",hytj_zcbyh);
        //1-3-2.今日新增B人数（总查券未购买）
        //int hytj_jrxzbrs = iAppUserSearchHistoryService.yesterdaySelectCountSearchCouponPeople(1,companyId,startTime,endTime);
        jsonObject.put("hytj_jrxzbrs",0);
        //1-3-3.昨日新增B人数（总查券未购买）
        int hytj_zrxzbrs = iAppUserSearchHistoryService.yesterdaySelectCountSearchCouponPeople(2,companyId, yestarStartTime, startTime);
        jsonObject.put("hytj_zrxzbrs",hytj_zrxzbrs);
        //1-4-1.总复购人数
        int hytj_zfgrs = iAppUserOrderService.OrderRepeat(companyId);
        jsonObject.put("hytj_zfgrs",hytj_zfgrs);
        //1-4-2.今日复购人数
        //int hytj_jrfgrs = iAppUserOrderService.yesterdayOrderRepeat(companyId,1,startTime,endTime);
        jsonObject.put("hytj_jrfgrs",0);
        //1-4-3.昨日复购人数
        int hytj_zrfgrs = iAppUserOrderService.yesterdayOrderRepeat(companyId,2, yestarStartTime, startTime);
        jsonObject.put("hytj_zrfgrs",hytj_zrfgrs);
        //1-5-1.总新增A占比(总下单用户/总注册用户)
        jsonObject.put("hytj_zxzazb",toPercentage(hytj_zxdyh,hytj_zzcrs));
        //1-5-2.今日新增A占比（今日新增下单用户/今日注册用户）
        //jsonObject.put("hytj_jrxzazb",toPercentage(hytj_jrxzars,hytj_jrzcs));
        jsonObject.put("hytj_jrxzazb",0);
        //1-5-3.昨日新增A占比(昨日新增下单用户/昨日注册用户)
        jsonObject.put("hytj_zrxzazb",toPercentage(hytj_zrxzars,hytj_zrzcs));

        //1-6-1.总新增B占比(总查券未购买/总注册用户)
        jsonObject.put("hytj_zxzbzb",toPercentage(hytj_zcbyh,hytj_zzcrs));
        //1-6-2.今日新增B占比(今日查券未购买/今日注册用户)
        //今日注册用户查券未购买数
        //int hytj_jrxzbrs_zc = iAppUserSearchHistoryService.selectCountSearchCouponPeopleNew(1,companyId,startTime,endTime);
        //jsonObject.put("hytj_jrxzbzb",toPercentage(hytj_jrxzbrs_zc,hytj_jrzcs));
        jsonObject.put("hytj_jrxzbzb",0);
        //1-6-3.昨日新增B占比（昨日查券未购买/昨日注册用户）
        int hytj_zrxzbrs_zc = iAppUserSearchHistoryService.selectCountSearchCouponPeopleNew(2,companyId,yestarStartTime, startTime);
        jsonObject.put("hytj_zrxzbzb",toPercentage(hytj_zrxzbrs_zc,hytj_zrzcs));

        //1-7-1.总复购用户占比(总复购用户/总注册用户)
        jsonObject.put("hytj_zfgyhzb",toPercentage(hytj_zfgrs,hytj_zzcrs));
        //1-7-2.今日复购用户占比（今日复购用户/今日注册用户）
        //jsonObject.put("hytj_jrfgyhzb",toPercentage(hytj_jrfgrs,hytj_jrzcs));
        jsonObject.put("hytj_jrfgyhzb",0);
        //1-7-3.昨日复购用户占比(昨日复购用户/昨日注册用户)
        jsonObject.put("hytj_zrfgyhzb",toPercentage(hytj_zrfgrs,hytj_zrzcs));
        //============《2.订单统计》=============
        //2-1-1.总订单数
        int ddtj_zdds = appUserOrderService.selectTotalOrder(companyId,0,startTime,endTime);
        jsonObject.put("ddtj_zdds",ddtj_zdds);
        //2-1-2.今日订单数
        //int ddtj_jrdds = appUserOrderService.selectTotalOrder(companyId,1, startTime, endTime);
        jsonObject.put("ddtj_jrdds",0);
        //2-1-3.昨日订单数
        int ddtj_zrdds = appUserOrderService.selectTotalOrder(companyId,2, yestarStartTime, startTime);
        jsonObject.put("ddtj_zrdds",ddtj_zrdds);
        //2-2-1.总首单数
        int ddtj_zsds = appUserOrderService.firstShareRatio(companyId,0,startTime,endTime);
        jsonObject.put("ddtj_zsds",ddtj_zsds);
        //2-2-2.今日首单数
        //int ddtj_jrsds = appUserOrderService.firstShareRatio(companyId,1, startTime, endTime);
        jsonObject.put("ddtj_jrsds",0);
        //2-2-3.昨日首单数
        int ddtj_zrsds = appUserOrderService.firstShareRatio(companyId,2, yestarStartTime, startTime);
        jsonObject.put("ddtj_zrsds",ddtj_zrsds);
        //2-3-1.总首单占比（总首单数/总订单数）
        jsonObject.put("ddtj_zsdzb",toPercentage(ddtj_zsds,ddtj_zdds));
        //2-3-2.今日首单占比(今日首单数/总订单数)
        //jsonObject.put("ddtj_jrsdzb",toPercentage(ddtj_jrsds,ddtj_zdds));
        jsonObject.put("ddtj_jrsdzb",0);
        //2-3-3.昨日首单占比(昨日首单数/总订单数)
        jsonObject.put("ddtj_zrsdzb",toPercentage(ddtj_zrsds,ddtj_zdds));
        //2-4-1.总新人0元购单数
        int ddtj_zxr0ygds = iAppOrderDetailService.totalGoodFrees(companyId,0,startTime,endTime);
        jsonObject.put("ddtj_zxr0ygds",ddtj_zxr0ygds);
        //2-4-2.今日新人0元购单数
        //int ddtj_jrxr0ygds = iAppOrderDetailService.totalGoodFrees(companyId,1, startTime, endTime);
        jsonObject.put("ddtj_jrxr0ygds",0);
        //2-4-3.昨日新人0元购单数
        int ddtj_zrxr0ygds = iAppOrderDetailService.totalGoodFrees(companyId,2, yestarStartTime, startTime);
        jsonObject.put("ddtj_zrxr0ygds",ddtj_zrxr0ygds);
        //2-5-1.总新人0元购占比(总新人0元购单数/总订单数)
        jsonObject.put("ddtj_zxr0ygzb",toPercentage(ddtj_zxr0ygds,ddtj_zdds));
        //2-5-2.今日新人0元购占比(今日新人0元购单数/总订单数)
        //jsonObject.put("ddtj_jrxr0ygzb",toPercentage(ddtj_jrxr0ygds,ddtj_zdds));
        jsonObject.put("ddtj_jrxr0ygzb",0);
        //2-5-3.昨日新人0元购占比(昨日新人0元购单数/总订单数)
        jsonObject.put("ddtj_zrxr0ygzb",toPercentage(ddtj_zrxr0ygds,ddtj_zdds));
        //2-6-1.总单笔0元购成本 (订单补贴金额 - 联盟返利金额 = 单笔0元购成本) / 单数
        double ddtj_zdb0ygcb = appUserOrderService.singleZeroPurchaseCost(companyId,0,startTime, endTime);
        jsonObject.put("ddtj_zdb0ygcb",ddtj_zdb0ygcb);
        //2-6-2.今日单笔0元购成本((今日订单补贴金额 - 今日联盟返利金额 = 单笔0元购成本) / 单数)
        //double ddtj_jrdb0ygcb = appUserOrderService.singleZeroPurchaseCost(companyId,1, startTime, endTime);
        jsonObject.put("ddtj_jrdb0ygcb",0);
        //2-6-3.昨日单笔0元购成本((昨日订单补贴金额 - 昨日联盟返利金额 = 单笔0元购成本) / 单数)
        double ddtj_zrdb0ygcb = appUserOrderService.singleZeroPurchaseCost(companyId,2, yestarStartTime, startTime);
        jsonObject.put("ddtj_zrdb0ygcb",ddtj_zrdb0ygcb);
        //2-7-1.总单粉产出(总有效佣金/总注册量)
        Double zyxyj = iAppUserOrderService.statisticsCommission(0, companyId,startTime, endTime);//1
        jsonObject.put("ddtj_zdfcc",handleDoubleDiv(zyxyj,hytj_zzcrs));
        //2-7-2.今日单粉产出(今日有效佣金/今日注册量)
        //Double jryxyj = iAppUserOrderService.statisticsCommission(1, companyId, startTime, endTime);
        //jsonObject.put("ddtj_jrdfcc",handleDoubleDiv(jryxyj.intValue(),hytj_zzcrs));//
        jsonObject.put("ddtj_jrdfcc",0);
        //2-7-3.昨日单粉产出(昨日有效佣金/昨日注册量)
        Double zryxyj = iAppUserOrderService.statisticsCommission(2, companyId, startTime, endTime);
        jsonObject.put("ddtj_zrdfcc",handleDoubleDiv(zryxyj,hytj_zzcrs));//
        //2-8-1.总A用户单产(总有效佣金/总新增下单用户)
        jsonObject.put("ddtj_zayhdc",handleDoubleDiv(zyxyj,hytj_zxdyh));//
        //2-8-2.今日A用户单产（今日有效佣金/总新增下单用户）
        //jsonObject.put("ddtj_jrayhdc",handleDoubleDiv(jryxyj.intValue(),hytj_zxdyh));
        jsonObject.put("ddtj_jrayhdc",0);
        //2-8-3.昨日A用户单产(昨日有效佣金/总新增下单用户）
        jsonObject.put("ddtj_zrayhdc",handleDoubleDiv(zryxyj,hytj_zxdyh));
        // ============《佣金统计》============
        //
        //============《渠道佣金》=============
        //1.老群渠道
        //2.微博渠道
        //3.中间页渠道
        //4.主动私聊渠道
        //5.自动回复渠道
        Integer groupId = 3;
        //4-1-1.总中间页渠道(联盟佣金)
        Double qdyj_zzjyqd = iAppUserOrderService.channelPubSharereFee(companyId,3,0);
        jsonObject.put("qdyj_zzjyqd",qdyj_zzjyqd);
        //4-1-2.今日中间页渠道
        //Double qdyj_jrzjyqd = iAppUserOrderService.channelPubSharereFee(companyId,3,1);
        jsonObject.put("qdyj_jrzjyqd",0);
        //4-1-3.昨日中间页渠道
        Double qdyj_zrzjyqd = iAppUserOrderService.channelPubSharereFee(companyId,3,2);
        jsonObject.put("qdyj_zrzjyqd",qdyj_zrzjyqd);
        //4-2-1.总主动私聊渠道(联盟佣金)
        Double qdyj_zzdslqd = iAppUserOrderService.channelPubSharereFee(companyId,4,0);
        jsonObject.put("qdyj_zzdslqd",qdyj_zzdslqd);
        //4-2-2.今日主动私聊渠道(联盟佣金)
        //Double qdyj_jrzdslqd = iAppUserOrderService.channelPubSharereFee(companyId,4,1);
        jsonObject.put("qdyj_jrzdslqd",0);
        //4-2-3.昨日主动私聊渠道(联盟佣金)
        Double qdyj_zrzdslqd = iAppUserOrderService.channelPubSharereFee(companyId,4,2);
        jsonObject.put("qdyj_zrzdslqd",qdyj_zrzdslqd);
        //4-3-1.总自动回复渠道(联盟佣金)
        Double qdyj_zzdhfqd = iAppUserOrderService.channelPubSharereFee(companyId,5,0);
        jsonObject.put("qdyj_zzdhfqd",qdyj_zzdhfqd);
        //4-3-2.今日自动回复渠道
        //Double qdyj_jrzdhfqd = iAppUserOrderService.channelPubSharereFee(companyId,5,1);
        jsonObject.put("qdyj_jrzdhfqd",0);
        //4-3-3.昨日自动回复渠道
        Double qdyj_zrzdhfqd = iAppUserOrderService.channelPubSharereFee(companyId,5,2);
        jsonObject.put("qdyj_zrzdhfqd",qdyj_zrzdhfqd);
        //4-4-1.总自然渠道(联盟佣金)
        Double qdyj_zzrqd = iAppUserOrderService.channelPubSharereFee(companyId,95,0);
        jsonObject.put("qdyj_zzrqd",qdyj_zzrqd);
        //4-4-2.今日自然渠道
        //Double qdyj_jrzrqd = iAppUserOrderService.channelPubSharereFee(companyId,95,1);
        jsonObject.put("qdyj_jrzrqd",0);
        //4-4-3.昨日自然渠道
        Double qdyj_zrzrqd = iAppUserOrderService.channelPubSharereFee(companyId,95,2);
        jsonObject.put("qdyj_zrzrqd",qdyj_zrzrqd);
        //4-5-1.总老群渠道(联盟佣金)
        Double qdyj_zlqqd = iAppUserOrderService.channelPubSharereFee(companyId,1,0);
        jsonObject.put("qdyj_zlqqd",qdyj_zlqqd);
        //4-5-2.今日老群渠道
        //Double qdyj_jrlqqd = iAppUserOrderService.channelPubSharereFee(companyId,1,1);
        jsonObject.put("qdyj_jrlqqd",0);
        //4-5-3.昨日老群渠道
        Double qdyj_zrlqqd = iAppUserOrderService.channelPubSharereFee(companyId,1,2);
        jsonObject.put("qdyj_zrlqqd",qdyj_zrlqqd);
        //4-6-1.总微博渠道佣金(联盟佣金)
        Double qdyj_zwbqdyj = iAppUserOrderService.channelPubSharereFee(companyId,2,0);
        jsonObject.put("qdyj_zwbqdyj",qdyj_zwbqdyj);
        //4-6-2.今日微博渠道佣金(联盟佣金)
        //Double qdyj_jrwbqdyj = iAppUserOrderService.channelPubSharereFee(companyId,2,1);
        jsonObject.put("qdyj_jrwbqdyj",0);
        //4-6-3.昨日微博渠道佣金(联盟佣金)
        Double qdyj_zrwbqdyj = iAppUserOrderService.channelPubSharereFee(companyId,2,2);
        jsonObject.put("qdyj_zrwbqdyj",qdyj_zrwbqdyj);
        //4-7-1.总全渠道佣金
        BigDecimal a1 = new BigDecimal(qdyj_zzjyqd.toString());
        BigDecimal a2 = new BigDecimal(qdyj_zzdslqd.toString());
        BigDecimal a3 = new BigDecimal(qdyj_zzdhfqd.toString());
        BigDecimal a4 = new BigDecimal(qdyj_zzrqd.toString());
        BigDecimal a5 = new BigDecimal(qdyj_zlqqd.toString());
        BigDecimal a6 = new BigDecimal(qdyj_zwbqdyj.toString());
        jsonObject.put("qdyj_zqqdyj",a1.add(a2).add(a3).add(a4).add(a5).add(a6));
        //4-7-2.今日全渠道佣金
        /*BigDecimal b1 = new BigDecimal(qdyj_jrzjyqd.toString());
        BigDecimal b2 = new BigDecimal(qdyj_jrzdslqd.toString());
        BigDecimal b3 = new BigDecimal(qdyj_jrzdhfqd.toString());
        BigDecimal b4 = new BigDecimal(qdyj_jrzrqd.toString());
        BigDecimal b5 = new BigDecimal(qdyj_jrlqqd.toString());
        BigDecimal b6 = new BigDecimal(qdyj_jrwbqdyj.toString());
        jsonObject.put("qdyj_jrqqdyj",b1.add(b2).add(b3).add(b4).add(b5).add(b6));*/
        jsonObject.put("qdyj_jrqqdyj",0);
        //4-7-3.昨日全渠道佣金
        BigDecimal c1 = new BigDecimal(qdyj_zrzjyqd.toString());
        BigDecimal c2 = new BigDecimal(qdyj_zrzdslqd.toString());
        BigDecimal c3 = new BigDecimal(qdyj_zrzdhfqd.toString());
        BigDecimal c4 = new BigDecimal(qdyj_zrzrqd.toString());
        BigDecimal c5 = new BigDecimal(qdyj_zrlqqd.toString());
        BigDecimal c6 = new BigDecimal(qdyj_zrwbqdyj.toString());
        jsonObject.put("qdyj_zrqqdyj",c1.add(c2).add(c3).add(c4).add(c5).add(c6));
        // ============《APP内部佣金》============
        //统计类型
        Integer types = 0;
        //5-1-1.总瀑布佣金(3,12,14)
        Double appnbyj_zpbyj = appUserOrderService.timeLimitedCommission(companyId,0,1);
        jsonObject.put("appnbyj_zpbyj",appnbyj_zpbyj);
        //5-1-2.今日瀑布佣金(3,12,14)
        //Double appnbyj_jrpbyj = appUserOrderService.timeLimitedCommission(companyId,1,1);
        jsonObject.put("appnbyj_jrpbyj",0);
        //5-1-3.昨日瀑布佣金(3,12,14)
        Double appnbyj_zrpbyj = appUserOrderService.timeLimitedCommission(companyId,2,1);
        jsonObject.put("appnbyj_zrpbyj",appnbyj_zrpbyj);
        //5-2-1.总搜索框佣金(18,19)
        Double appnbyj_zsskyj = appUserOrderService.timeLimitedCommission(companyId,0,2);
        jsonObject.put("appnbyj_zsskyj",appnbyj_zsskyj);
        //5-2-2.今日搜索框佣金(18,19)
        //Double appnbyj_jrsskyj = appUserOrderService.timeLimitedCommission(companyId,1,2);
        jsonObject.put("appnbyj_jrsskyj",0);
        //5-2-3.昨日搜索框佣金(18,19)
        Double appnbyj_zrsskyj = appUserOrderService.timeLimitedCommission(companyId,2,2);
        jsonObject.put("appnbyj_zrsskyj",appnbyj_zrsskyj);
        //5-3-1.总淘口令查询佣金（1，2，3，4）
        Double appnbyj_ztklcxyj = appUserOrderService.timeLimitedCommission(companyId,0,3);
        jsonObject.put("appnbyj_ztklcxyj",appnbyj_ztklcxyj);
        //5-3-2.今日淘口令查询佣金（1，2，3，4）
        //Double appnbyj_jrtklcxyj = appUserOrderService.timeLimitedCommission(companyId,1,3);
        jsonObject.put("appnbyj_jrtklcxyj",0);
        //5-3-3.昨日淘口令查询佣金（1，2，3，4）
        Double appnbyj_zrtklcxyj = appUserOrderService.timeLimitedCommission(companyId,1,3);
        jsonObject.put("appnbyj_zrtklcxyj",appnbyj_zrtklcxyj);
        //5-4-1.总标题搜索佣金(5)
        Double appnbyj_zbtssyj = appUserOrderService.timeLimitedCommission(companyId,0,4);
        jsonObject.put("appnbyj_zbtssyj",appnbyj_zbtssyj);
        //5-4-2.今日标题搜索(5)
        //Double appnbyj_jrbtssyj = appUserOrderService.timeLimitedCommission(companyId,1,4);
        jsonObject.put("appnbyj_jrbtssyj",0);
        //5-4-3.昨日标题搜索(5)
        Double appnbyj_zrbtssyj = appUserOrderService.timeLimitedCommission(companyId,2,4);
        jsonObject.put("appnbyj_zrbtssyj",appnbyj_zrbtssyj);
        //5-5-1.总后返佣金(固定返)
        Double appnbyj_zhfyj = appUserOrderService.singleFixedReturnYesterday(companyId,0);
        jsonObject.put("appnbyj_zhfyj",appnbyj_zhfyj);
        //5-5-2.今日后返佣金(固定返)
        //Double appnbyj_jrhfyj = appUserOrderService.singleFixedReturnYesterday(companyId,1);
        jsonObject.put("appnbyj_jrhfyj",0);
        //5-5-3.昨日后返佣金(固定返)
        Double appnbyj_zrhfyj = appUserOrderService.singleFixedReturnYesterday(companyId,2);
        jsonObject.put("appnbyj_zrhfyj",appnbyj_zrhfyj);
        //5-6-1.总大促活动佣金
        //Double appnbyj_zdchdyj = appUserOrderService.timeLimitedCommission(companyId,0,6);
        jsonObject.put("appnbyj_zdchdyj",0);
        //5-6-2.今日大促销活动佣金
        //Double appnbyj_jrdchdyj = appUserOrderService.timeLimitedCommission(companyId,0,6);
        jsonObject.put("appnbyj_jrdchdyj",0);
        //5-6-3.昨日大促销活动佣金
        //Double appnbyj_zrdchdyj = appUserOrderService.timeLimitedCommission(companyId,0,6);
        jsonObject.put("appnbyj_zrdchdyj",0);
        //============《支出数据》=============
        //6-1-1.总邀请人数
        int zcsj_zyqrs = iAppUserService.numberOfInvitations(0,companyId);
        jsonObject.put("zcsj_zyqrs",zcsj_zyqrs);
        //6-1-2.今日邀请人数
        //int zcsj_jryqrs = iAppUserService.numberOfInvitations(1,companyId);
        jsonObject.put("zcsj_jryqrs",0);
        //6-1-3.昨日邀请人数
        int zcsj_zryqrs = iAppUserService.numberOfInvitations(2,companyId);
        jsonObject.put("zcsj_zryqrs",zcsj_zryqrs);
        //6-2-1.总邀请奖励
        Double zcsj_zyqjl = iAppUserService.totalInvitationCost(companyId,0);
        jsonObject.put("zcsj_zyqjl",zcsj_zyqjl);
        //6-2-2.今日邀请奖励
        //Double zcsj_jryqjl = iAppUserService.totalInvitationCost(companyId,1);
        jsonObject.put("zcsj_jryqjl",0);
        //6-2-3.昨日邀请奖励
        Double zcsj_zryqjl = iAppUserService.totalInvitationCost(companyId,2);
        jsonObject.put("zcsj_zryqjl",zcsj_zryqjl);
        //6-3-1.总签到金额
        Double zcsj_zqdje = iAppUserRedRewardService.totalSignAmount(companyId,0);
        jsonObject.put("zcsj_zqdje",zcsj_zqdje);
        //6-3-2.今日签到金额
        //Double zcsj_jrqdje = iAppUserRedRewardService.totalSignAmount(companyId,1);
        jsonObject.put("zcsj_jrqdje",0);
        //6-3-3.昨日签到金额
        Double zcsj_zrqdje = iAppUserRedRewardService.totalSignAmount(companyId,2);
        jsonObject.put("zcsj_zrqdje",zcsj_zrqdje);
        //6-4-1.总新人复制链接红包(??新人任务红包)
        Double zcsj_zxrfzljhb = iAppUserRedRewardService.totalRedEnvelopeForBeginners(companyId,1,0);
        jsonObject.put("zcsj_zxrfzljhb",zcsj_zxrfzljhb);
        //6-4-2.今日新人复制链接红包
        //Double zcsj_jrxrfzljhb = iAppUserRedRewardService.totalRedEnvelopeForBeginners(companyId,1,1);
        jsonObject.put("zcsj_jrxrfzljhb",0);
        //6-4-3.昨日新人复制链接红包
        Double zcsj_zrxrfzljhb = iAppUserRedRewardService.totalRedEnvelopeForBeginners(companyId,1,2);
        jsonObject.put("zcsj_zrxrfzljhb",zcsj_zrxrfzljhb);
        //6-5-1.总新人首单红包
        Double zcsj_zxrsdhb  = iAppUserRedRewardService.totalRedEnvelopeForBeginners(companyId,2,0);
        jsonObject.put("zcsj_zxrsdhb",zcsj_zxrsdhb);
        //6-5-2.今日新人首单红包
        //Double zcsj_jrxrsdhb  = iAppUserRedRewardService.totalRedEnvelopeForBeginners(companyId,2,1);
        jsonObject.put("zcsj_jrxrsdhb",0);
        //6-5-3.昨日新人首单红包
        Double zcsj_zrxrsdhb  = iAppUserRedRewardService.totalRedEnvelopeForBeginners(companyId,2,2);
        jsonObject.put("zcsj_zrxrsdhb",zcsj_zrxrsdhb);
        //6-6-1.总提现金额
        Double zcsj_ztxje = iAppWithdrawalService.statisticsAmount(companyId,0);
        jsonObject.put("zcsj_ztxje",zcsj_ztxje);
        //6-6-2.今日提现金额
        //Double zcsj_jrtxje = iAppWithdrawalService.statisticsAmount(companyId,1);
        jsonObject.put("zcsj_jrtxje",0);
        //6-6-3.昨日提现金额
        Double zcsj_zrtxje = iAppWithdrawalService.statisticsAmount(companyId,2);
        jsonObject.put("zcsj_zrtxje",zcsj_zrtxje);
        //6-7-1.总提现人数
        int zcsj_ztxrs = iAppWithdrawalService.statisticsPeopleAmount(companyId,0);
        jsonObject.put("zcsj_ztxrs",zcsj_ztxrs);
        //6-7-2.今日提现人数
        //int zcsj_jrtxrs = iAppWithdrawalService.statisticsPeopleAmount(companyId,1);
        jsonObject.put("zcsj_jrtxrs",0);
        //6-7-3.昨日提现人数
        int zcsj_zrtxrs = iAppWithdrawalService.statisticsPeopleAmount(companyId,2);
        jsonObject.put("zcsj_zrtxrs",zcsj_zrtxrs);
        //============《APP活跃》==============

        //存储缓存
        redisTemplateService.set(redisKey,jsonObject,3600*24);
    }

    @Override
    public JSONObject jsonUmengList(Integer companyId) {
        JSONObject jsonObject = new JSONObject();
        //============《APP活跃》==============
        Integer apphy_jrxzyh =0;
        Integer apphy_zrxzyh =0;
        Integer apphy_jrhyyh =0;
        Integer apphy_zrhyyh =0;
        Integer apphy_jrqdcs =0;
        Integer apphy_zrqdcs =0;
        Integer apphy_zljyh =0;
        OpenApiUtil test = new OpenApiUtil();
        String openApiDate = test.getAllDate();
        if(openApiDate != null && (companyId == null||companyId ==1)){
            JSONArray array = (JSONArray)JSONObject.parseObject(openApiDate).get("allAppData");
            JSONObject json = (JSONObject)array.get(0);
            apphy_jrxzyh = (Integer)json.get("todayNewUsers");
            apphy_zrxzyh = (Integer)json.get("yesterdayNewUsers");
            apphy_jrhyyh = (Integer)json.get("todayActivityUsers");
            apphy_zrhyyh = (Integer)json.get("yesterdayActivityUsers");
            apphy_jrqdcs = (Integer)json.get("todayLaunches");
            apphy_zrqdcs = (Integer)json.get("yesterdayLaunches");
            apphy_zljyh = (Integer)json.get("totalUsers");
        }
        //7-1-1.今日新增用户
        jsonObject.put("apphy_jrxzyh",apphy_jrxzyh==null?0:apphy_jrxzyh);
        //7-1-2.昨日新增用户
        jsonObject.put("apphy_zrxzyh",apphy_zrxzyh==null?0:apphy_zrxzyh);
        //7-2-1.今日活跃用户
        jsonObject.put("apphy_jrhyyh",apphy_jrhyyh==null?0:apphy_jrhyyh);
        //7-2-2.昨日活跃用户
        jsonObject.put("apphy_zrhyyh",apphy_zrhyyh==null?0:apphy_zrhyyh);
        //7-3-1.今日启动次数
        jsonObject.put("apphy_jrqdcs",apphy_jrqdcs==null?0:apphy_jrqdcs);
        //7-3-2.昨日启动次数
        jsonObject.put("apphy_zrqdcs",apphy_zrqdcs==null?0:apphy_zrqdcs);
        //7-4-1.总累计用户
        jsonObject.put("apphy_zljyh",apphy_zljyh==null?0:apphy_zljyh);

        //7-4-2.昨日累计用户
        Integer apphy_zrljyh = 0;
        //安卓的昨日总用户:0
        String androidApp = new OpenApiUtil().getTodayYesterdayDat(0);
        //ios昨日总用户: 1
        String iosApp = new OpenApiUtil().getTodayYesterdayDat(1);
        if(androidApp != null && iosApp != null && (companyId == null||companyId ==1)){
            //将json字符串转化成json对象
            JSONObject androidYesterdayData = (JSONObject) JSONObject.parseObject(androidApp).get("yesterdayData");
            Integer androidTotalUsers =(Integer)androidYesterdayData.get("totalUsers");
            JSONObject iosYesterdayData = (JSONObject) JSONObject.parseObject(iosApp).get("yesterdayData");
            Integer iosTotalUsers = (Integer)iosYesterdayData.get("totalUsers");
            //ios + 安卓
            if(androidTotalUsers == null){
                androidTotalUsers = 0;
            }
            if(iosTotalUsers == null){
                iosTotalUsers = 0;
            }
            apphy_zrljyh = androidTotalUsers + iosTotalUsers;
        }
        jsonObject.put("apphy_zrljyh",apphy_zrljyh);
        return jsonObject;
    }

    @Override
    @Async
    public void jsonTabListTask(Integer companyId, int type) {
        String redisKey = "jsonTabList_" + type + "_" + DateFormatUtils.getNowDateDay(new Date()) + "_" + companyId;
        JSONObject jsonTabList = new JSONObject();
        // ============《佣金统计》============
        //今日数据：0
        //昨日数据：1
        //近7日数据：2
        //近30日数据：3
        //本月数据：4
        //上月数据：5
        //全部数据：6
        Long startDate = null;
        Long endDate = null;
        switch (type){
            case 0 :
                startDate = DateUtils.getTimesmorning().getTime();
                break;
            case 1 :
                startDate = DateUtils.getYesterdaymorning().getTime();
                endDate = DateUtils.getTimesmorning().getTime();
                break;
            case 2 :
                startDate = DateUtils.getWeekFromNow().getTime();
                break;
            case 3 :
                startDate = DateUtils.getMonthFromNow().getTime();
                break;
            case 4 :
                startDate = DateUtils.getTimesMonthmorning().getTime();
                break;
            case 5 :
                startDate = DateUtils.getLastMonthStartMorning().getTime();
                endDate = DateUtils.getTimesMonthmorning().getTime();
                break;
        }
        //---------------------------------------
        Integer flag = 0;
        //3-1.联盟佣金
        Double yjtj_lmyj = appUserOrderService.freeAllianceCommissionYesterday(companyId,type,startDate,endDate);
        jsonTabList.put("yjtj_lmyj",yjtj_lmyj);
        //3-2.净收益
        Double yjtj_jsy = appUserOrderService.pubCommisssionPubSharePreFee(companyId,type,startDate,endDate);
        jsonTabList.put("yjtj_jsy",yjtj_jsy);
        //3-3.支付订单数
        Integer yjtj_zfdds = appUserOrderService.payOrderTotalNum(companyId,type,startDate,endDate);
        jsonTabList.put("yjtj_zfdds",yjtj_zfdds);
        //3-4.支付订单补贴
        Double yjtj_zfddbt = appUserOrderService.payOrderTotalMoney(companyId,type,startDate,endDate);
        jsonTabList.put("yjtj_zfddbt",yjtj_zfddbt);
        //3-5.0元购单数
        Integer orderType = 0;
        int yjtj_0ygds = appUserOrderService.totalGoodFreesNum(companyId,0,type,startDate,endDate);
        jsonTabList.put("yjtj_0ygds",yjtj_0ygds);
        //3-6.0元购补贴
        Double yjtj_0ygbt = appUserOrderService.totalGoodFreesMoney(companyId,0,type,startDate,endDate);
        jsonTabList.put("yjtj_0ygbt",yjtj_0ygbt);
        //3-7.结算订单数
        int yjtj_jsdds = appUserOrderService.totalGoodFreesNum(companyId,1,type,startDate,endDate);
        jsonTabList.put("yjtj_jsdds",yjtj_jsdds);
        //3-8.结算用户补贴
        Double yjtj_jsyhbt = appUserOrderService.totalGoodFreesMoney(companyId,1,type,startDate,endDate);
        jsonTabList.put("yjtj_jsyhbt",yjtj_jsyhbt);
        //3-9.申请提现笔数
        Integer applicantStatus = 0;
        Integer yjtj_sqtxbs = iAppWithdrawalService.statisticsAmountNum(companyId,0,type,startDate,endDate);
        jsonTabList.put("yjtj_sqtxbs",yjtj_sqtxbs);
        //3-10.申请提现金额
        Double yjtj_sqtxje = iAppWithdrawalService.statisticsAmountMoney(companyId,0,type,startDate,endDate);
        jsonTabList.put("yjtj_sqtxje",yjtj_sqtxje);
        //3-11.已提现笔数
        Integer yjtj_ytxbs = iAppWithdrawalService.statisticsAmountNum(companyId,1,type,startDate,endDate);
        jsonTabList.put("yjtj_ytxbs",yjtj_ytxbs);
        //3-12.已提现金额
        Double yjtj_ytxje = iAppWithdrawalService.statisticsAmountMoney(companyId,1,type,startDate,endDate);
        jsonTabList.put("yjtj_ytxje",yjtj_ytxje);

        //存储缓存
        redisTemplateService.set(redisKey,jsonTabList,3600*24);
    }


}
